<template>
	<view class="">
	  <u-tabbar v-model="current" :list="list" :hideTabBar="false" :before-switch="beforeSwitch"
		activeColor="#fe582b" inactiveColor="#999999"></u-tabbar>
	</view>
</template>

<script>
	export default {
		name:"supplier-tabbar",
		props: {
			supplierId: {
				type: [String, Number],
				default: ''
			},
			index: {
				type: [String, Number],
				default: ''
			},
		},
		data() {
			return {
				list: [{
					iconPath: "/static/supplier/tabbar/home.png",
					selectedIconPath: "/static/supplier/tabbar/home-active.png",
					text: '首页',
					customIcon: false,
				},
				{
					iconPath: "/static/supplier/tabbar/category.png",
					selectedIconPath: "/static/supplier/tabbar/category-active.png",
					text: '全部商品',
					customIcon: false,
				},
				{
					iconPath: "/static/supplier/tabbar/shopgwc.png",
					selectedIconPath: "/static/supplier/tabbar/shopgwc.png",
					text: '购物车',
					customIcon: false,
				},
				{
					iconPath: "/static/supplier/tabbar/shopwd.png",
					selectedIconPath: "/static/supplier/tabbar/shopwd.png",
					text: '我的',
					customIcon: false,
				},
				{
					iconPath: "/static/supplier/tabbar/shopfh.png",
					selectedIconPath: "/static/supplier/tabbar/shopfh.png",
					text: '返回商城',
					customIcon: false,
				},
			],
			current: 0
			};
		},
		mounted() {
			this.current = this.index
		},
		methods: {
			beforeSwitch(index) {
				switch (index){
					case 0:
						if(this.index == index) return
						this.index = 0
						uni.redirectTo({
							url: '/pages/supplierPage/supplierIndex/supplierIndex?id=' + this.supplierId
						})
						break;
					case 1:
						if(this.index == index) return
						this.index = 1
						uni.reLaunch({
							url: '/pages/supplierPage/supplierAllGoods/supplierAllGoods?id=' + this.supplierId
						})
						break;
					case 2:
						uni.switchTab({
							url:'/pages/tabbar/cart/cart'
						})
						break;
					case 3:
						uni.switchTab({
							url:'/pages/tabbar/mine/mine'
						})
						break;
					case 4:
						uni.switchTab({
							url:'/pages/tabbar/index/index'
						})
						break;
					default:
						break;
				}
			}
		}
	}
</script>

<style lang="scss">

</style>
